<template>
	<!-- 红包 -->
	<view class="mainpadding">
		 <u-sticky bgColor="#fff">
		    <u-subsection :list="subsection" mode="button" :current="current" @change="changeList()"></u-subsection>
		  </u-sticky>
		  <view class="flexcenter" style="margin-top: 300rpx;" v-if="!list.data.length">
		  	<view class="placeholderimage"></view>
		  </view>
		<view class="hongbao " v-for="item in list.data" :key="item.id">
			<view class="top" :class="current==0?'bacc1':current==1?'bacc2':'bacc3'">
				<view class="p1"></view>
				<view class="p2"></view>
				<view class="topLeft">
					<view class="t1">{{item.price}}</view>
					<view class="t1right">
						<view class="r1 fw">元</view>
						<view class="r2">满{{item.mj_price}}减{{item.price}}</view>
						<view class="r2">{{item.name}}</view>
						<view class="" v-if="current==0">{{item.end_time_text}}过期</view>
						<view class="fw"  style="font-size: 32rpx;">{{item.goods_type==1?"全部商品":"部分商品"}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require('@/commonFun/httpRequest.js');
	export default {
		data() {
			return {
				subsection: ['待使用', '已使用', '已过期'],
				current:0,
				page:1,
				limit:10,
				list:{
					data:[],
				},
			};
		},
		onLoad() {
			this.init()
		},
		methods: {
			changeList(e){
				this.list = {
					data:[]
				}
				this.current = e
				this.init()
			},
			init(isPage,page){
				let _this = this;
				let obj = {
					"0":10,
					"1":20,
					"2":30
				}
				httpRequest.request('/customapi/user/myCoupon','POST',{
					page:page||1,
					limit:_this.limit,
					status:obj[_this.current],
				}).then(res => {
					if(res.code == 1){
						let resList = res.data;
						let dataList = _this.list;
						if(isPage == true){
							_this.list.data.push(...resList.data);
						}else {
							_this.list = resList;
							_this.list.data = resList.data;
						}
					}else{
						httpRequest.toast(res.msg);
					}
				})
			},
			onReachBottom(){
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.lastpage <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.getdata(true, page);
			},
		}
	};
</script>

<style scoped lang="scss">
	.bacc1{
		background: linear-gradient(to right, #ff6f89, #ff4860);
	}
	.bacc2{
		background: linear-gradient(to right, #1a73e8, #1a73e8);
	}
	.bacc3{
		background: linear-gradient(to right, #999, #999);
	}
	.hongbao {
		margin-top: 30rpx;
		font-size: 32rpx;
	
		.top {
			
			padding: 30rpx 40rpx;
			display: flex;
			justify-content: space-between;
			color: #ffffff;
			border-radius: 8px;
			position: relative;
	
			.p1 {
				position: absolute;
				bottom: 50%;
				left: -50rpx;
				transform: translate(50%, 50%);
				background-color: rgb(245, 245, 245);
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
			}
	
			.p2 {
				position: absolute;
				bottom: 50%;
				right: 0rpx;
				transform: translate(50%, 50%);
				background-color: rgb(245, 245, 245);
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
			}
	
			.topLeft {
				display: flex;
				justify-content: space-between;
	
				.t1 {
					font-size: 65rpx;
				}
	
				.t1right {
					flex-direction: column;
					display: flex;
					justify-content: space-around;
					margin-left: 20rpx;
	
					.r1 {
						font-size: 38rpx;
					}
	
					.r2 {}
				}
			}
	
			
		}
	
		.bottom {
			background-color: #ffffff;
			padding: 30rpx 0;
			text-align: center;
			border-radius: 8px;
			color: #ff4961;
			font-size: 32rpx;
			box-shadow: 0px 0px 20rpx 0px rgba(0, 0, 0, 0.2);
		}
	}
	.topRight {
					text-align: right;
					display: flex;
					flex-direction: column;
					justify-content: space-around;

					.t1 {
						font-size: 24rpx;
					}
				}

	.fw {
		font-weight: 900;
	}

	.fc1 {
		color: #3a96ff !important;
	}

	.fc2 {
		color: #ff8d1f !important;
	}

	.fc3 {
		color: #03a0bd !important;
	}
</style>
